C51 COMPILER V9.52.0.0   MAIN                                                              09/28/2022 19:54:06 PAGE 1   


C51 COMPILER V9.52.0.0, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN .\Release\main.obj
COMPILER INVOKED BY: C:\Keil_v4\C51\BIN\C51.EXE main.c OPTIMIZE(0,SPEED) REGFILE(.\Release\Sample_DrvWDT.ORC) BROWSE INC
                    -DIR(..\..\..\..\C51SIS\C51;..\..\..\Include\Driver) DEBUG OBJECTEXTEND TABS(2) OBJECT(.\Release\main.obj)

line level    source

   1          /**************************************************************************//**
   2           * @file           main.c
   3           * @version        V1.0
   4           * $Revision:      1 $
   5           * $Date:          2017/01/04 $
   6           * @brief          Main function
   7           * @Author         Jeffrey Kang
   8           * @ContactInfo    chkang@esmt.com.tw
   9           *
  10           * @note
  11           *
  12           * Copyright (C) 1998 Elite Semiconductor Memory Technology Corp.
  13           * All rights reserved.
  14           *
  15           ******************************************************************************/
  16          
  17          
  18          #include <REG52.h>
  19          #include "system_FE81001.h"
  20          
  21          
  22          #define WRITE_PROTECT      0xA5
  23          #define MAGIC_NUM          0x5A
  24          
  25          
  26          volatile unsigned char cnt = 0;
  27          
  28          
  29          /**
  30           * @brief       delay function
  31           *
  32           * @param       None
  33           *
  34           * @return      None
  35           *
  36           * @details     1. 
  37           */
  38          void delay (int cnt )
  39          {
  40   1        unsigned int i , j ;
  41   1        
  42   1        for(j=0 ; j<cnt ; j++)
  43   1        for( i = 0 ; i < 200 ; i++ ); 
  44   1        
  45   1      }
  46          
  47          
  48          /**
  49           * @brief       TCKISR function
  50           *
  51           * @param       None
  52           *
  53           * @return      None
  54           *
C51 COMPILER V9.52.0.0   MAIN                                                              09/28/2022 19:54:06 PAGE 2   

  55           * @details     1. 
  56           */
  57          const void WDTISR (void) interrupt ISR_WDT
  58          {
  59   1        /* clear interrupt flag */
  60   1        unsigned char int_stat = WDT->status;
  61   1        WDT->status = 0x01;
  62   1      
  63   1        /* Restart WDT */
  64   1        //WDT_Reset();
  65   1        
  66   1        /* enable global interrupt */
  67   1        INTC->int_gmask = 0x01;
  68   1      }
  69          
  70          
  71          /**
  72           * @brief       WDTInit function
  73           *
  74           * @param       None
  75           *
  76           * @return      None
  77           *
  78           * @details     1. 
  79           */
  80          void WDTInit(void)
  81          {
  82   1        /* Enable DT write protect */
  83   1        En_WDT_WriteProtect();
  84   1      
  85   1        /* Set Reset Time */
  86   1        Reset_Time_Period_x1024();  // Period = 1/32768  i.e. Interrupt time  = 0.03125s
  87   1        
  88   1        /* Set Interrupt Time */
  89   1        Interrupt_Time_Period_x32768(); // Period = 1/32768  i.e. Interrupt time  = 1s
  90   1        
  91   1        /* WDT Enable */
  92   1        WDT_Reset_Enable();
  93   1        WDT_INTEN_Enable();
  94   1        WDT_WDTEN_Enable();
  95   1      }
  96          
  97          
  98          /**
  99           * @brief       WDTClkInit function
 100           *
 101           * @param       None
 102           *
 103           * @return      None
 104           *
 105           * @details     1. 
 106           */
 107          void WDTClkInit (void)
 108          {
 109   1        /* enable LSRC clock */
 110   1        LSRCEN_Enable();          
 111   1      
 112   1        /* Select LSRC clock */
 113   1        WDT_Set_clock_LSRC();
 114   1        
 115   1        /* wait LSRC stable */
 116   1        while((CLKC->clkstb & 0x04)!= 0x04){}
C51 COMPILER V9.52.0.0   MAIN                                                              09/28/2022 19:54:06 PAGE 3   

 117   1        
 118   1        /* enable WDT clock */
 119   1        En_WDT_clk();
 120   1      }
 121          
 122          
 123          /**
 124           * @brief       main function
 125           *
 126           * @param       None
 127           *
 128           * @return      None
 129           *
 130           * @details     1. 
 131           */
 132          int main( void )
 133          {
 134   1        /* Enable PA PB PC PD Clock */
 135   1        PORT_PAPBPCPD_Clock_Enable();
 136   1        
 137   1        /* Set PC7 input as button */
 138   1        PORT_SetPCInput(BIT7);
 139   1      
 140   1        /* Set PD1. ,PD2.,PD3 output */
 141   1        PORT_SetPDPushPull(BIT1 | BIT2 | BIT3 );
 142   1        
 143   1        /* Toggle  LED when WDT happen */
 144   1        PD1 =0;
 145   1        PD2 =0;
 146   1        PD3 =0;
 147   1        delay(500);
 148   1      
 149   1        PD1 =1;
 150   1        PD2 =1;
 151   1        PD3 =1;
 152   1        delay(500);
 153   1      
 154   1        /* enable WDT clock */
 155   1        WDTClkInit();
 156   1        
 157   1        /* WDT init */
 158   1        WDTInit();
 159   1        
 160   1        /* enable global interrupt */
 161   1        INTC->int_gmask = 0x01;
 162   1        
 163   1        while(1)
 164   1        {
 165   2          // Reset WDT in Interrupt 
 166   2        }
 167   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    379    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      8    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.

C51 COMPILER V9.52.0.0   MAIN                                                              09/28/2022 19:54:06 PAGE 4   


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)
